<?php
namespace app\api\controller;
use think\Input;
use think\Controller;
use app\common\controller\Base;
use app\admin\model\Areas;
use app\admin\model\Clouds;
class Cloud extends Base{
	/*获取所有的云供应商*/
	public function suppliers(){
		$cloud = new Clouds;
		$suppliers = $cloud->getClouds();
		if($suppliers){
			$data = [];
			foreach($suppliers as $k=>$v){
				$v['name'] = lang($v['name']);
				$data[$k] = $v; 
			}
			return ['code'=>0,'items'=>$data,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
	/*获取供应商下的所有地区*/
	public function countrys($itemId=0){
		$countrys = Clouds::getCountry($itemId);
        if($countrys){
			return ['code'=>0,'items'=>$countrys,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
	/*获取供应商下的所有城市*/
	public function citys($itemId=0,$countryId=0){
		$citys = Clouds::getCity($itemId,$countryId);
        if($citys){
			return ['code'=>0,'items'=>$citys,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
	public function items($itemId=0,$countryId=0,$cityId=0){
		$items = Clouds::getItems($itemId,$countryId,$cityId);
        if($items){
			return ['code'=>0,'items'=>$items,'msg'=>'success'];
		}
		return ['code'=>-1,'msg'=>lang('Failed.')];
	}
}